﻿Imports DTO
Public Class TiecCuoi_DAL
    Dim connect As Connection
    Dim stringCommand As String
    Dim tiecCuoi As TiecCuoi
    Dim ds_TiecCuoi As List(Of TiecCuoi)

    Public Function LoadData() As List(Of TiecCuoi)
        connect = New Connection()
        stringCommand = "Select * From TiecCuoi"
        ds_TiecCuoi = New List(Of TiecCuoi)
        Dim dt As New DataTable()
        dt = connect.LoadData(stringCommand)
        For i As Integer = 0 To dt.Rows.Count - 1
            Dim id As Integer = dt.Rows(i)(0)
            Dim tenChuRe As String = dt.Rows(i)(1).ToString()
            Dim tenCoDau As String = dt.Rows(i)(2).ToString()
            Dim dienThoai As String = dt.Rows(i)(3).ToString()
            Dim ngay As DateTime = dt.Rows(i)(4)
            Dim ca As Integer = dt.Rows(i)(5)
            Dim sanh As Integer = dt.Rows(i)(6)
            Dim tienDatCoc As Double = dt.Rows(i)(7)
            Dim soLuongBan As String = dt.Rows(i)(8).ToString()
            Dim soBanDuTru As String = dt.Rows(i)(9).ToString()
            tiecCuoi = New TiecCuoi(id, tenChuRe, tenCoDau, dienThoai, ngay, ca, sanh, tienDatCoc, soLuongBan, soBanDuTru)
            ds_TiecCuoi.Add(tiecCuoi)
        Next
        Return ds_TiecCuoi
    End Function

    Public Function Insert(ByVal tiecCuoi As TiecCuoi)
        connect = New Connection()
        stringCommand = "Insert TiecCuoi(ID,TenChuRe,TenCoDau,DienThoai,Ngay,Ca,Sanh,TienDatCoc,SoLuongBan,SoBanDuTru) Values('" & tiecCuoi.ID & "','" & tiecCuoi.Tên_Chú_Rễ & "','" & tiecCuoi.Tên_Cô_Dâu & "','" & tiecCuoi.Điện_Thoại & "','" & tiecCuoi.Ngày & "','" & tiecCuoi.Ca & "','" & tiecCuoi.Sảnh & "','" & tiecCuoi.Tiền_Đặt_Cọc & "','" & tiecCuoi.Số_Lượng_Bàn & "','" & tiecCuoi.Số_Bàn_Dự_Trữ & ")"
        Return connect.ExecuteData(stringCommand)
    End Function

    Public Function Delete(ByVal tiecCuoi As TiecCuoi)
        connect = New Connection()
        stringCommand = "Delete From TiecCuoi Where ID = " & tiecCuoi.ID
        Return connect.ExecuteData(stringCommand)
    End Function
End Class
